//
//  RegisterViewController.m
//  01-UIViewHomeWork
//
//  Created by dllo on 16/7/21.
//  Copyright © 2016年 QC.L. All rights reserved.
//  注册界面

#import "RegisterViewController.h"
#import "LoginView.h"
#import "BaseTabBarController.h"
#import "AppDelegate.h"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
@interface RegisterViewController ()<LoginViewDelegate, UITextFieldDelegate>
@property (nonatomic, strong) LoginView *loginView;
@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.hidden = YES;
    [self creatLoginView];
    
}

- (void)creatLoginView {
    self.loginView = [[LoginView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    _loginView.delegate = self;
    [self.view addSubview:_loginView];
    [_loginView.userButton setImage:[UIImage imageNamed:@"icon_telephone"] forState:UIControlStateNormal];
    [_loginView.userButton setImage:[UIImage imageNamed:@"icon_telephone_select"] forState:UIControlStateSelected];
    _loginView.userTextField.placeholder = @"请输入手机号";
    _loginView.userTextField.delegate = self;
    [_loginView.passwordButton setImage:[UIImage imageNamed:@"icon_safe"] forState:UIControlStateNormal];
    [_loginView.passwordButton setImage:[UIImage imageNamed:@"icon_safe_select"] forState:UIControlStateSelected];
    _loginView.passwordTextField.placeholder = @"请输入验证码";
    _loginView.passwordTextField.delegate = self;
    [_loginView.forgetButton removeFromSuperview];
    [_loginView.loginButton setTitle:@"注册" forState:UIControlStateNormal];
    [_loginView.registerButton setTitle:@"返回登录" forState:UIControlStateNormal];
}

#pragma mark - LoginView协议方法
- (void)jumpViewController:(UIButton *)button {
    if ([button.titleLabel.text isEqualToString:@"返回登录"]) {
        [self.navigationController popViewControllerAnimated:NO];
    }
    else if ([button.titleLabel.text isEqualToString:@"随便逛逛"]) {
        BaseTabBarController *baseTabBar = [[BaseTabBarController alloc] init];
        AppDelegate *app = [UIApplication sharedApplication].delegate;
        app.window.rootViewController = baseTabBar;
    }

}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
    if (textField == _loginView.userTextField) {
        _loginView.userButton.selected = YES;
        _loginView.passwordButton.selected = NO;
        return YES;
    } else {
        _loginView.userButton.selected = NO;
        _loginView.passwordButton.selected = YES;
        return YES;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
